<template>
  <div class="problem-description">
    <el-tabs type="border-card" value="tabDescription">
      <el-tab-pane label="题目描述" name="tabDescription">
        <el-form :model="problem" label-width="80px">
          <el-form-item label="题目名称">
            <div
              style="
                background-color: #f6f6f6;
                padding: 0 20px;
                border-radius: 4px;
              "
            >
              {{ this.problem.title }}
            </div>
          </el-form-item>
          <el-form-item label="题目难度">
            <el-rate
              v-if="problem.difficulty"
              v-model="problem.difficulty"
              :max="3"
              :texts="['简单', '中等', '困难']"
              show-text
              disabled
            ></el-rate>
            <el-tag v-else disable-transitions>待定</el-tag>
          </el-form-item>
          <el-form-item label="题目描述">
            <div
              style="
                background-color: #f6f6f6;
                padding: 0 20px;
                border-radius: 4px;
              "
            >
              {{ problem.content }}
            </div>
          </el-form-item>
        </el-form>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "ProblemDescription",
  components: {},
  mounted() {
    this.getProblem();
  },
  methods: {
    getProblem() {
      let pid = this.$route.params.pid;
      axios
        .get("/api/problem/show", {
          params: {
            pid: pid,
          },
        })
        .then((response) => {
          console.log(response);
          if (response.data.status == 1) {
            this.problem = response.data.result.problem;
            this.$message.success("获取题目成功");
            this.$emit("deliverProblem", this.problem);
          }
        })
        .catch((error) => {
          console.log(error);
          this.$message.error("获取题目失败");
          this.$emit("deliverProblem", this.problem);
        });
    },
  },
  data() {
    return {
      problem: {},
      // problem: {
      //   _id: "",
      //   title: "",
      //   difficulty: 0,
      //   content: "",
      //   status: 0,
      // },
    };
  },
};
</script>

<style></style>
